package com.timerecording.controller;

import com.timerecording.common.SwaggerTagConst;
import com.timerecording.common.controller.LoginAdminBaseController;
import com.timerecording.domain.entity.LoginEntity;
import com.timerecording.domain.vo.login.CaptchaVO;
import com.timerecording.service.login.LoginService;
import com.timerecording.util.ResponseDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author smz41
 * @description: TODO
 * @date 2024/4/10
 */
@CrossOrigin  //解决跨域
@RestController
@Api(tags = {SwaggerTagConst.Admin.LOGIN})
public class LoginController extends LoginAdminBaseController {

    @Autowired
    private LoginService loginService;


    /**  登录
     * @description: TODO
     * @author smz
     * @version 1.0
     * @date 2025/1/26
     */
    @ApiOperation("登录 @author smz")
    @PostMapping("/login/getLogin")
    public ResponseDTO getLogin(@RequestBody LoginEntity loginEntity){
        ResponseDTO login = loginService.login(loginEntity);
        return ResponseDTO.succData(login,"登陆成功");
    }



    /** 获取验证码
     * @description: TODO
     * @author smz
     * @version 1.0
     * @date 2025/1/26
     */
    @ApiOperation("获取验证码 @author smz")
    @GetMapping("/login/getCaptcha")
    public ResponseDTO<CaptchaVO>  getCaptcha(){
        return loginService.getCaptcha();
    }


    /** 退出登录
     * @description: TODO
     * @author smz
     * @version 1.0
     * @date 2025/7/26
     */
    @PostMapping("/loginout")
    public ResponseDTO loginout(@RequestHeader("Authorization") String token){
        loginService.loginout(token);
        return ResponseDTO.succMsg("退出登陆成功！！！");
    }


    /** 修改密码
     * @description: TODO
     * @author smz
     * @version 1.0
     * @date 2025/1/26
     */


    /** 重置密码
     * @description: TODO
     * @author smz
     * @version 1.0
     * @date 2025/1/26
     */
    @GetMapping("/login/resetPassword/{employeeId}")
    public ResponseDTO<String> resetPassword(@PathVariable Long employeeId){
        return loginService.resetPassword(employeeId);
    }


}
